package com.zxy.furns.dao.impl;

import com.zxy.furns.dao.BasicDAO;
import com.zxy.furns.dao.MemberDAO;
import com.zxy.furns.entity.Member;

import javax.print.DocFlavor;

/**
 * ClassName: memberDAOImpl
 * Package: com.zxy.furns.dao.impl
 *
 * @Author zxy
 * @Create 2025/3/20 21:42
 * @Version 1.0
 * title:
 * Description:
 */
public class MemberDAOImpl extends BasicDAO<Member> implements MemberDAO {
    @Override
    public int saveMember(Member member) {

        String sql = "INSERT INTO member(`username`, `password`, `email`) VALUES (?, MD5(?), ?);";
        return update(sql, member.getUsername(), member.getPassword(), member.getEmail());
    }

    @Override
    public Member queryMemberByUsername(String username) {
        String sql = "SELECT `id`,`username`,`password`,`email` FROM member where username=?";
        return querySingle(sql, Member.class, username);
    }

    @Override
    public Member queryMemberByUsernameAndPassword(String username, String password) {
        String sql = "SELECT id,username,password,email FROM member WHERE username=? AND password=MD5(?)";
        return querySingle(sql, Member.class, username, password);
    }
}
